import type { UploadFile } from 'element-plus'
import { apiGet, apiPost } from '../func/fetch'
import type { DayStatistcsObj, FlightOperateLogList, FlightScheduleDetail, FlightScheduleForm, FlightScheduleList, FlightSchedulePageParmas, GetDeviceDesc } from './type'
import type { PageResult } from '@/api/global.ts'
import { ContentType } from '@/api/global.ts'

const _api = import.meta.env.VITE_FACEID_URL
// <-- 航班计划 -->
// 航班计划分页查询
export const flightSchedulePageApi = (params: FlightSchedulePageParmas): Promise<PageResult<FlightScheduleList>> => {
  return apiPost(`${_api}/flightSchedule/page`, params, ContentType.X_WWW_FORM_URLENCODED)
}
// 航班计划新增
export const flightScheduleSaveApi = (params: FlightScheduleForm): Promise<null> => {
  return apiPost(`${_api}/flightSchedule/save`, params)
}
// 航班计划编辑
export const flightScheduleUpdateApi = (params: FlightScheduleForm): Promise<null> => {
  return apiPost(`${_api}/flightSchedule/update`, params)
}
// 导入
export const importExcelApi = (file: { file: UploadFile }): Promise<null> => {
  return apiPost(`${_api}/flightSchedule/importExcel`, file, ContentType.MULTIPART_FORM_DATA)
}
// 作废
export const flightScheduleCancelApi = (params: { id: string, flightState: string }): Promise<null> => {
  return apiPost(`${_api}/flightSchedule/cancel`, params)
}
// 删除
export const flightScheduleDeleteApi = (params: { id: string }): Promise<null> => {
  return apiPost(`${_api}/flightSchedule/delete`, params)
}
// 查询登机口下拉列表
export const getDeviceDescByAreaIdApi = (): Promise<GetDeviceDesc> => {
  return apiGet(`${_api}/flightSchedule/checkInCounterAndBoardingGateList`)
}
// 详情
export const flightOperateLogDetailApi = (params: { flightId: string }): Promise<FlightOperateLogList[]> => {
  return apiPost(`${_api}/flightOperateLog/detail`, params)
}
// 某天航班统计
export const dayStatisticsApi = (params: { scheduleTakeOffDay: number }): Promise<DayStatistcsObj> => {
  return apiGet(`${_api}/flightSchedule/flightStatistics`, params)
}
// AIOT值机口登机口
export const deviceDescApi = (params: { areaId: 'zj' | 'dj' }): Promise<string[]> => {
  return apiPost('/bp-acs/device/getDeviceDescByAreaId', params, ContentType.APPLICATION_JSON)
}
// 航班计划管理详情
export const flightScheduleDetailApi = (params: { id: string }): Promise<FlightScheduleDetail> => {
  return apiPost(`${_api}/flightSchedule/detail`, params)
}
